using System;
using System.IO;
using System.Collections;
using Mono.Unix;
using System.Xml;

namespace Tomboy
{

	public class TomboyDataProviderFile : TomboyDataProvider
	{

		static private TomboyDataProvider provider = null;
		
		public TomboyDataProviderFile()
		{
			if (provider==null) {
				provider = this;
			}
		}
		
		public bool DirectoryExist(string directory) {
			return Directory.Exists (directory);
		}
		
		public DirectoryInfo CreateDirectory (string directory)
		{
			return Directory.CreateDirectory (directory);
		}
		
		public bool FileExists (string filePath) {
			return File.Exists(filePath);
		}

		public bool FileDelete (string filePath) {
			File.Delete(filePath);
			return true;
		}
		
		public void FileMove (string fileSource, string fileDest)
		{
			File.Move(fileSource,fileDest);
		}

		public string [] DirectoryGetFiles (string notes_dir, string pattern) {
			return Directory.GetFiles (notes_dir, pattern);
		}

		public XmlTextWriter getXmlTextWriter (string tmp_file, System.Text.Encoding encoding)
		{
			XmlTextWriter xml = new XmlTextWriter (tmp_file, encoding);
			return xml;
		}

		public XmlTextReader getXmlTextReader (string read_file, System.Text.Encoding encoding)
		{
			StreamReader reader = new StreamReader (read_file, encoding);
			XmlTextReader xml = new XmlTextReader (reader);
			return xml;
		}

		public void textWriterClose (XmlTextWriter writer) 
		{
			writer.Close ();
		}
		
		public void xmlDocumentSave(XmlDocument document,String filename) {
			document.Save(filename);
		}
		
		public void XmlDocumentLoad(XmlDocument document,String filename) {
			document.Load(filename);
		}

	}
}
